package com.gui.hospital.controller;

import com.gui.entity.DateUtils;
import com.gui.hospital.model.NumberSource;
import com.gui.hospital.service.NumberSourceService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author 言叶
 * Date：2025/9/4
 */
@RestController
@RequestMapping("/numberSource")
@CrossOrigin
@AllArgsConstructor
public class NumberSourceController {
    private NumberSourceService numberSourceService;
    //根据时间和医生的id查询可用的号源信息

    /*
    * @param time
    * @param doctorId
    * @return
    * @description: 根据时间和医生的id查询可用的号源信息
     */
    @GetMapping("/findByTimeAndDoctorId")
    public List<NumberSource> findByTimeAndDoctorId(String date, Integer doctorId) {
        Date dateTime = DateUtils.dateTime("yyyy-MM-dd", date);
        return numberSourceService.findByTimeAndDoctorId(dateTime, doctorId);
    }

    /*
    修改号源状态
     */
    @PutMapping("/updateStatusById/{id}/{status}")
    public boolean updateStatusById(@PathVariable("id") Long id, @PathVariable("status") Long status) {
        return numberSourceService.updateStatusById(id, status);
    }
}
